package org.setec.manager;

import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.webapp.WebAppContext;

import java.net.URL;

public class Manager {

    public static void startManagerServer(int port) throws Exception {

        final Server server = new Server(port);

        final String webAppDir = "org/setec/manager";
        final String contextPath = "/mm";

        final URL warUrl = Manager.class.getClassLoader().getResource(webAppDir);
        final String warUrlString = warUrl.toExternalForm();
        server.setHandler(new WebAppContext(warUrlString, contextPath));

        final Context context = new Context(server, "/mms", Context.SESSIONS);
        context.addServlet(new ServletHolder(new ManagerServlet()), "/manager");

        server.start();

    }



    public static void main(String[] args){
        try {
            startManagerServer(8081);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}